home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ May 89 / U0019-Re Later Versions-May89 < prev    next >
Encoding:
Text File  |  1989-06-26  |  2.0 KB  |  54 lines  |  [TEXT/GEOL]

  1. Item    6783579                         8-May-89        11:37
  2.  
  3. From:   ALGER                           Alger, Jeff
  4.  
  5. To:     CH0095                          CH DEV PEMD Group
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    Response to Later Versions
  10.  
  11. Ernie,
  12.  
  13. Not to beat this horse to death, but there is another mechanism for handling
  14. changing versions of objects.  If your GraphRecord corresponds to some object
  15. class TGraphObject, then you can use subclasses of TGraphObject to represent
  16. specific versions (this was pointed out by Chuck Lins in his response.)
  17.  
  18. If you choose this architecture, the global function NewObjectByClassName and
  19. an IRes method in TGraphObject can combine to solve the problem.  Place the
  20. subclass name in the data immediately preceeding the record itself.  Assume
  21. that p is a pointer to the class name as read in to memory.  Then the following
  22. code fragment gives the general idea:
  23.  
  24. VAR
  25.     myClassName:    Str255;
  26.     p:              UNIV Ptr;
  27.     myObject:       TGraphObject;
  28. BEGIN
  29.  
  30. myClassName := StringPtr(p)^;
  31. myObject := TGraphObject(NewObjectByClassName(myClassName));
  32. p := p + LENGTH(myClassName)+1;
  33. myObject.IRes(p);
  34.  
  35.  
  36. This is the way MacApp initializes views in 2.0, so it is not a "hokey" way of
  37. doing things.  However, it does require the overhead of keeping class names in
  38. the data.  And, of course, you must keep the old subclass names around.
  39. However, it does successfully isolate the knowledge of how to handle old
  40. versions of arbitrary classes to the subclasses themselves.  To make this work,
  41. you should also have a WRes method to write out the data from the subclass.
  42.  
  43. I use the names "IRes" and "WRes" because those are the names used by MacApp
  44. for views, which always initialize from resources.  However, the same scheme
  45. works for other in-memory data structures and, with little modification, for
  46. reading the data from a data fork as requested.
  47.  
  48. I do not know if this is applicable to your situation, but I thought it worth a
  49. mention.
  50.  
  51. Jeff Alger
  52. Peat Marwick Main & Co.
  53.  
  54.